home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 8: LINUX Games / Linux Cubed Series 8 - LINUX Games.iso / games / video / zapem-0.000 / zapem-0 / zapem / asmblock.S < prev    next >
Text File  |  1994-11-26  |  5KB  |  275 lines

  1. #include "screendefs.h"
  2.  
  3. .text
  4. .align 4
  5.  
  6. .globl _moveblock
  7. _moveblock:
  8.     pushl %ebp
  9.     movl %esp,%ebp
  10.     
  11.     pushl %esi
  12.     pushl %edi
  13.  
  14.     pushl %eax
  15.     pushl %ebx
  16.     pushl %ecx
  17.     pushl %edx
  18.         
  19.     movl 8(%ebp),%esi    !source
  20.     movl 12(%ebp),%edi    !dest
  21.     movl 16(%ebp),%ecx    
  22.     movl %ecx,%eax        
  23.  
  24.     shrl $3,%ecx        /* shift right byte 3 bits same as div by 8 */
  25.     movl %ecx,16(%ebp)    /* save result on stack */    
  26.     movl $SCREENWIDTH,%edx  /* calulate line adjustment */
  27.     subl %eax,%edx
  28.     movl %edx,%eax
  29.     movl 20(%ebp),%edx        
  30. moveline:
  31.     movl 16(%ebp),%ecx
  32. linemove:
  33.     movsl
  34.     movsl
  35.     loop linemove
  36.     movl %esi,%ebx    /* move to start of next line */
  37.     addl %eax,%ebx
  38.     movl %ebx,%esi
  39.     movl %edi,%ebx
  40.     addl %eax,%ebx
  41.     movl %ebx,%edi
  42.  
  43.     decl %edx    /*decrement y counter*/
  44.     jne moveline    
  45.  
  46.     popl %edx
  47.     popl %ecx
  48.     popl %ebx
  49.     popl %eax
  50.  
  51.     popl %edi
  52.     popl %esi
  53.         
  54.     movl %ebp,%esp
  55.     popl %ebp
  56.     ret
  57.  
  58. .globl _cutblock
  59. _cutblock:
  60.     pushl %ebp
  61.     movl %esp,%ebp
  62.     
  63.     pushl %esi
  64.     pushl %edi
  65.  
  66.     pushl %eax
  67.     pushl %ebx
  68.     pushl %ecx
  69.     pushl %edx
  70.         
  71.     movl 8(%ebp),%esi    !source
  72.     movl 12(%ebp),%edi    !dest
  73.     movl 16(%ebp),%ecx    
  74.     movl %ecx,%eax        
  75.  
  76.     shrl $3,%ecx        /* shift right byte 3 bits same as div by 8 */
  77.     movl %ecx,16(%ebp)    /* save result on stack */    
  78.     movl $SCREENWIDTH,%edx  /* calulate line adjustment */
  79.     subl %eax,%edx
  80.     movl %edx,%eax
  81.     movl 20(%ebp),%edx        
  82. copyline:
  83.     movl 16(%ebp),%ecx
  84. linecopy:
  85.     movsl
  86.     movsl
  87.     loop linecopy
  88.     movl %esi,%ebx
  89.     addl %eax,%ebx
  90.     movl %ebx,%esi
  91.  
  92.     decl %edx    /*decrement y counter*/
  93.     jne copyline    
  94.  
  95.     popl %edx
  96.     popl %ecx
  97.     popl %ebx
  98.     popl %eax
  99.  
  100.     popl %edi
  101.     popl %esi
  102.         
  103.     movl %ebp,%esp
  104.     popl %ebp
  105.     ret
  106.  
  107. .align 4
  108. .globl _pasteblock
  109. _pasteblock:
  110.     pushl %ebp
  111.     movl %esp,%ebp
  112.     
  113.     pushl %esi
  114.     pushl %edi
  115.  
  116.     pushl %eax
  117.     pushl %ebx
  118.     pushl %ecx
  119.     pushl %edx
  120.         
  121.     movl 8(%ebp),%esi    !source
  122.     movl 12(%ebp),%edi    !dest
  123.     movl 16(%ebp),%ecx    !x width
  124.     movl %ecx,%eax    
  125.     shrl $3,%ecx        /*adjust for a 48bit width*/
  126.     movl %ecx,16(%ebp)    /*write back new value*/
  127.     movl $SCREENWIDTH,%edx
  128.     subl %eax,%edx        /*calulate line adjustment*/
  129.     movl %edx,%eax
  130.     movl 20(%ebp),%edx    /*height*/    
  131. copyline2:
  132.     movl 16(%ebp),%ecx
  133. linecopy2:
  134.     movsl
  135.     movsl
  136.     loop linecopy2
  137.     movl %edi,%ebx
  138.     addl %eax,%ebx
  139.     movl %ebx,%edi
  140.  
  141.     decl %edx    /*decrement y counter*/
  142.     jne copyline2    
  143.  
  144.     popl %edx
  145.     popl %ecx
  146.     popl %ebx
  147.     popl %eax
  148.  
  149.     popl %edi
  150.     popl %esi
  151.         
  152.     movl %ebp,%esp
  153.     popl %ebp
  154.     ret
  155.  
  156. .align 4
  157. .globl _andpasteblock
  158. _andpasteblock:
  159.     pushl %ebp
  160.     movl %esp,%ebp
  161.  
  162.     pushl %esi
  163.     pushl %edi
  164.  
  165.     pushl %eax
  166.     pushl %ebx
  167.     pushl %ecx
  168.     pushl %edx
  169.         
  170.     movl 8(%ebp),%esi    !source (mask)
  171.     movl 12(%ebp),%edi    !dest
  172.     movl 16(%ebp),%ecx    !x width
  173.     movl %ecx,%eax    
  174.     shrl $3,%ecx        /*adjust for a 32bit width*/
  175.     movl %ecx,16(%ebp)    /*write back new value*/
  176.     movl $SCREENWIDTH,%edx
  177.     subl %eax,%edx        /*calulate line adjustment*/
  178.  
  179. copyline3:
  180.     movl 16(%ebp),%ecx
  181. linecopy3:
  182.     lodsl             /* load si into eax and increment si */
  183.     andl %eax,(%edi)    /* AND block uint32 into destination */ 
  184.     incl %edi        /* increment destination address */
  185.     incl %edi        /* increment destination address */
  186.     incl %edi        /* increment destination address */
  187.     incl %edi        /* increment destination address */
  188.  
  189.     lodsl             /* load si into eax and increment si */
  190.     andl %eax,(%edi)    /* AND block uint32 into destination */ 
  191.     incl %edi        /* increment destination address */
  192.     incl %edi        /* increment destination address */
  193.     incl %edi        /* increment destination address */
  194.     incl %edi        /* increment destination address */
  195.     loop linecopy3
  196.  
  197.     movl %edi,%ebx
  198.     addl %edx,%ebx
  199.     movl %ebx,%edi
  200.  
  201.     decl 20(%ebp)    /*decrement y counter*/
  202.     jne copyline3    
  203.  
  204.     popl %edx
  205.     popl %ecx
  206.     popl %ebx
  207.     popl %eax
  208.  
  209.     popl %edi
  210.     popl %esi
  211.         
  212.     movl %ebp,%esp
  213.     popl %ebp
  214.     ret
  215.  
  216. .align 4
  217. .globl _xorpasteblock
  218. _xorpasteblock:
  219.     pushl %ebp
  220.     movl %esp,%ebp
  221.  
  222.     pushl %esi
  223.     pushl %edi
  224.  
  225.     pushl %eax
  226.     pushl %ebx
  227.     pushl %ecx
  228.     pushl %edx
  229.         
  230.     movl 8(%ebp),%esi    !source (mask)
  231.     movl 12(%ebp),%edi    !dest
  232.     movl 16(%ebp),%ecx    !x width
  233.     movl %ecx,%eax    
  234.     shrl $3,%ecx        /*adjust for a 32bit width*/
  235.     movl %ecx,16(%ebp)    /*write back new value*/
  236.     movl $SCREENWIDTH,%edx
  237.     subl %eax,%edx        /*calulate line adjustment*/
  238.  
  239. copyline4:
  240.     movl 16(%ebp),%ecx
  241. linecopy4:
  242.     lodsl             /* load si into eax and increment si */
  243.     xorl %eax,(%edi)    /* AND block uint32 into destination */ 
  244.     incl %edi        /* increment destination address */
  245.     incl %edi        /* increment destination address */
  246.     incl %edi        /* increment destination address */
  247.     incl %edi        /* increment destination address */
  248.  
  249.     lodsl             /* load si into eax and increment si */
  250.     xorl %eax,(%edi)    /* AND block uint32 into destination */ 
  251.     incl %edi        /* increment destination address */
  252.     incl %edi        /* increment destination address */
  253.     incl %edi        /* increment destination address */
  254.     incl %edi        /* increment destination address */
  255.     loop linecopy4
  256.  
  257.     movl %edi,%ebx
  258.     addl %edx,%ebx
  259.     movl %ebx,%edi
  260.  
  261.     decl 20(%ebp)    /*decrement y counter*/
  262.     jne copyline4
  263.  
  264.     popl %edx
  265.     popl %ecx
  266.     popl %ebx
  267.     popl %eax
  268.  
  269.     popl %edi
  270.     popl %esi
  271.         
  272.     movl %ebp,%esp
  273.     popl %ebp
  274.     ret
  275.